class CategoryModel {
  String code;
  String message;
  List<Data> data;

  CategoryModel({this.code, this.message, this.data});

  CategoryModel.fromJson(Map<String, dynamic> json) {
    code = json['code'];
    message = json['message'];
    if (json['data'] != null) {
      //data=json['data'].map((i)=>new Data.fromJson(i)).toList();
      //或者
      data = new List<Data>();
      json['data'].forEach((v) {
        data.add(new Data.fromJson(v));
      });
      
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

//分类数据,中分类
class Data {
  String mallCategoryId;//类别编号
  String mallCategoryName;//类别名称
  List<BxMallSubDto> bxMallSubDto;//小类列表
  Null comments;//类别图片
  String image;//列表描述
//构造函数
  Data({this.mallCategoryId,this.mallCategoryName,this.bxMallSubDto, this.comments,this.image});

//工厂模式的构造方法,用这种模式可以省略New关键字
  Data.fromJson(Map<String, dynamic> json) {//dynamic格式也可以
    mallCategoryId = json['mallCategoryId'];
    mallCategoryName = json['mallCategoryName'];
    if (json['bxMallSubDto'] != null) {
      bxMallSubDto = new List<BxMallSubDto>();
      json['bxMallSubDto'].forEach((v) {
        bxMallSubDto.add(new BxMallSubDto.fromJson(v));
      });
    }
    comments = json['comments'];
    image = json['image'];
  }



  //工厂模式-用这种模式可以省略New关键字
  //   factory Data.fromJson(dynamic json){
  //   return Data(
  //     mallCategoryId:json['mallCategoryId'],
  //     mallCategoryName:json['mallCategoryName'],
  //     comments:json['comments'],
  //     image:json['image'],
  //     bxMallSubDto:json['bxMallSubDto']
  //   );
  // }
  // factory Data.fromJson(dynamic json)=> Data(
  //     mallCategoryId:json['mallCategoryId'],
  //     mallCategoryName:json['mallCategoryName'],
  //     comments:json['comments'],
  //     image:json['image'],
  //     bxMallSubDto:json['bxMallSubDto']
  //   );







  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['mallCategoryId'] = this.mallCategoryId;
    data['mallCategoryName'] = this.mallCategoryName;
    if (this.bxMallSubDto != null) {
      data['bxMallSubDto'] = this.bxMallSubDto.map((v) => v.toJson()).toList();
    }
    data['comments'] = this.comments;
    data['image'] = this.image;
    return data;
  }
}

class BxMallSubDto {
  String mallSubId;
  String mallCategoryId;
  String mallSubName;
  String comments;

  BxMallSubDto(
      {this.mallSubId, this.mallCategoryId, this.mallSubName, this.comments});

  BxMallSubDto.fromJson(Map<String, dynamic> json) {
    mallSubId = json['mallSubId'];
    mallCategoryId = json['mallCategoryId'];
    mallSubName = json['mallSubName'];
    comments = json['comments'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['mallSubId'] = this.mallSubId;
    data['mallCategoryId'] = this.mallCategoryId;
    data['mallSubName'] = this.mallSubName;
    data['comments'] = this.comments;
    return data;
  }
}